<?php
class ActlotteryAction extends CommonAction{
	/**
	 * 营销活动首页
	 */
	public function lottery_index(){
		
		$json = sendRest("Actlottery/select");
	
		$this->assign("list",$json);
		$this->display();
	}
	
	/**
	 * 大转盘
	 */
	public function lottery_rotate(){
		
		$model = D("Actlottery");
		
		if(IS_AJAX){
		
			$data  = $model->checkUserWinning();
		
			$this->ajaxReturn($data);
				
		}else{
				
			$data  = $model->getLotteryDetail();
				
			$this->assign("detail",$data);
			$this->display();
		}
	}
	
	/**
	 * 刮刮卡
	 */
	public function lottery_scratch(){
		
		$model = D("Actlottery");
		
		if(IS_AJAX){
		
			$data  = $model->checkUserWinning();
		
			$this->ajaxReturn($data);
				
		}else{
				
			$data  = $model->getLotteryDetail();
				
			$this->assign("detail",$data);
			$this->display();
		}
		
	}
	
	/**
	 * 翻牌
	 */
	public function lottery_flop(){
		
		$model = D("Actlottery");
		
		if(IS_AJAX){
		
			$data  = $model->checkUserWinning();
		
			$this->ajaxReturn($data);
				
		}else{
				
			$data  = $model->getLotteryDetail();
				
			$this->assign("detail",$data);
			$this->display();
		}
	}
	
	/**
	 * 摇一摇
	 */
	public function lottery_shake(){
		
		$model = D("Actlottery");
		$data  = $model->getLotteryDetail();
		
		$this->assign("detail",$data);
		$this->display();
		
	}
	
	/**
	 * 砸金蛋
	 */
	public function lottery_hiteggs(){
		
		$model = D("Actlottery");
		
		if(IS_AJAX){
				
			$data  = $model->checkUserWinning();
				
			$this->ajaxReturn($data);
			
		}else{
			
			$data  = $model->getLotteryDetail();
			
			$this->assign("detail",$data);
			$this->display();
		}
		
		
	}
	
	/**
	 * 九宫格
	 */
	public function lottery_squared(){
		
		$model = D("Actlottery");
		
		if(IS_AJAX){
			
			$data  = $model->checkUserWinning();
			
			$this->ajaxReturn($data);
		}else{

			$data  = $model->getLotteryDetail();
			
			$this->assign("detail",$data);
			$this->display();
		}
	}
	
	/**
	 * 用户中奖填写表单
	 * 中奖表单提交
	 */
	public function lottery_prize(){
		
		$detail = session(C("USER_AUTH_PRIZE"));
		$logid  = $this->_param("logid");
		$actid  = $this->_param("actid");
		
		if(IS_POST){
			
			$model = M("ActlotteryLog");
			if($model->create()){
		
				$map = $model->data();
				$map['logid'] = $logid;
		
				unset($_SESSION[C('USER_AUTH_PRIZE')]);
				$json = sendRest("Actlottery/fillings",$map);
			}
		}else{
			
			$this->assign("detail",$detail);
			
			$this->display();
		}
	}
	
	
	
}
?>